package com.appwoo.android.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public abstract class BaseActivity extends Activity
{
  private static final String TAG = "BaseActivity";

  public static byte[] getImage(String paramString)
    throws IOException
  {
    HttpURLConnection localHttpURLConnection = (HttpURLConnection)new URL(paramString).openConnection();
    localHttpURLConnection.setConnectTimeout(5000);
    localHttpURLConnection.setRequestMethod("GET");
    InputStream localInputStream = localHttpURLConnection.getInputStream();
    if (localHttpURLConnection.getResponseCode() == 200)
      return readStream(localInputStream);
    return null;
  }

  public static byte[] readStream(InputStream paramInputStream)
    throws IOException
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte = new byte[1024];
    while (true)
    {
      int i = paramInputStream.read(arrayOfByte);
      if (i == -1)
      {
        localByteArrayOutputStream.close();
        paramInputStream.close();
        return localByteArrayOutputStream.toByteArray();
      }
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
    }
  }

  public void IntentActivity(Context paramContext, Class<?> paramClass)
  {
    startActivity(new Intent(paramContext, paramClass));
  }

  public void IntentActivity(Context paramContext, Class<?> paramClass, Bundle paramBundle)
  {
    Intent localIntent = new Intent(paramContext, paramClass);
    Bundle localBundle = new Bundle();
    if (paramBundle != null)
      localBundle.putAll(paramBundle);
    localIntent.putExtras(localBundle);
    startActivity(localIntent);
  }

  public Drawable LoadImage(String paramString)
  {
    try
    {
      Drawable localDrawable = Drawable.createFromStream((InputStream)new URL(paramString).getContent(), "image");
      return localDrawable;
    }
    catch (MalformedURLException localMalformedURLException)
    {
      Log.e("BaseActivity", localMalformedURLException.getMessage());
      return null;
    }
    catch (IOException localIOException)
    {
      Log.e("BaseActivity", localIOException.getMessage());
    }
    return null;
  }

  public void alertMessage(String paramString)
  {
    Toast.makeText(this, paramString, 0).show();
  }

  public void backAcitvity(Context paramContext)
  {
    ((Activity)paramContext).setResult(-1, getIntent());
    ((Activity)paramContext).finish();
  }

  public void hiddenKeyBord(Context paramContext)
  {
    InputMethodManager localInputMethodManager = (InputMethodManager)getSystemService("input_method");
    View localView = ((Activity)paramContext).getCurrentFocus();
    if (localView != null)
    {
      IBinder localIBinder = localView.getWindowToken();
      if (localIBinder != null)
        localInputMethodManager.hideSoftInputFromWindow(localIBinder, 2);
    }
  }

  public Drawable loadImage(String paramString)
  {
    try
    {
      Drawable localDrawable = Drawable.createFromStream((InputStream)new URL(paramString).getContent(), "test");
      return localDrawable;
    }
    catch (MalformedURLException localMalformedURLException)
    {
      Log.e("exception", localMalformedURLException.getMessage());
      return null;
    }
    catch (IOException localIOException)
    {
      while (true)
        Log.e("exception", localIOException.getMessage());
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.android.activity.BaseActivity
 * JD-Core Version:    0.6.2
 */